package managedbean;

import entity.StaffAccountEntity;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseEvent;
import javax.faces.model.SelectItem;
import session.stateless.TCubeSessionBean;

@ManagedBean
@ViewScoped
public class StaffUnlockAccountManagedBean {

    private List<StaffAccountEntity> accountList;
    private String accountSelected;
    private SelectItem[] accountSelectedItems;
    @EJB
    private TCubeSessionBean sessionBean;

    public StaffUnlockAccountManagedBean() {
    }

    public String getAccountSelected() {
        return accountSelected;
    }

    public void setAccountSelected(String accountSelected) {
        this.accountSelected = accountSelected;
    }

    public SelectItem[] getAccountSelectedItems() {
        return accountSelectedItems;
    }

    public void setAccountSelectedItems(SelectItem[] accountSelectedItems) {
        this.accountSelectedItems = accountSelectedItems;
    }

    public void initView(PhaseEvent event) {

        accountSelectedItems = new SelectItem[2];
        accountSelectedItems[0] = new SelectItem("Tourist Account", "Tourist Account");
        accountSelectedItems[1] = new SelectItem("StakeHolder Account", "StakeHolder Account");
    }

    public List<StaffAccountEntity> getAccountList() {
        return accountList;
    }

    public void setAccountList(List<StaffAccountEntity> accountList) {
        this.accountList = accountList;
    }
    
    public void selectAccount(ActionEvent event)
    {
        if(accountSelected.equalsIgnoreCase("Tourist Account"))
        {
            accountList = sessionBean.getTCubeAccountList();
        }
    }
    public void confirmChanges (ActionEvent event)
    {
        for(int i=0; i<getAccountList().size(); i++)
        {
            sessionBean.updateStatus(getAccountList().get(i));
        }
    }
}
